
<%@ page import="pojo.Tcm" %>
<%@ page import="java.util.List" %>
<%@ page import="dto.TcmDetailDto" %>
<%@ page import="util.PageUtil" %><%--
  Created by IntelliJ IDEA.
  User: 13615
  Date: 2021/9/9
  Time: 14:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>中药模块</title>
    <style type="text/css">
        table {
            border-collapse: collapse;
        }
        a:link {
            text-decoration: none;
        }

        a:visited {
            text-decoration: none;
        }

        a:hover {
            text-decoration: underline;
        }

        a:active {
            text-decoration: underline;
        }
        #customers {
            font-family: Arial, Helvetica, sans-serif;
            border-collapse: collapse;
            width: 100%;
        }

        #customers td, #customers th {
            border: 1px solid #ddd;
            padding: 8px;
        }

        #customers tr:nth-child(even){background-color: #f2f2f2;}

        #customers tr:hover {background-color: #ddd;}

        #customers th {
            padding-top: 12px;
            padding-bottom: 12px;
            text-align: left;
            background-color: #4CAF50;
            color: white;
        }
    </style>
</head>
<script>
    function BackToList(){
        location.href="/TcmSystem/TcmServlet?action=list&curPage=1";
    }
    function SearchByName(){
        var key=document.getElementById("name").value;
        location.href="/TcmSystem/TcmServlet?action=search&flag=0&key="+key;
    }
    function SearchByAlias(){
        var key=document.getElementById("alias").value;
        location.href="/TcmSystem/TcmServlet?action=search&flag=1&key="+key;
    }
    function SearchByBjyw(){
        var key=document.getElementById("bjyw").value;
        location.href="/TcmSystem/TcmServlet?action=search&flag=2&key="+key;
    }
    function del(id){
        if(confirm("确认删除该中药的记录吗?")){
            location.href="/TcmSystem/TcmServlet?action=delete&id="+id;
        }
    }
</script>
<body>
<%
    PageUtil pu=(PageUtil)request.getAttribute("tcmList");
    List<Tcm> tcmList=pu.getList();
    int curPage=(int)request.getAttribute("curPage");
%>
<h1 align="center">中药信息展示</h1>
<div align="center">
    <form action="#" method="post">
    <table>
        <tr>
            <td>
                名称查询:
                <input type="text" id="name" name="name"/>
                <input type="button" value="查询" onclick="SearchByName();">
            </td>
            <td>
                别名查询:
                <input type="text" id="alias" name="alias"/>
                <input type="button" value="查询" onclick="SearchByAlias();">
            </td>
            <td>
                名称查询:
                <input type="text" id="bjyw" name="bjyw"/>
                <input type="button" value="查询" onclick="SearchByBjyw();">
            </td>
        </tr>
    </table>
    </form>
</div>

<table id="customers" border="2" width="1000px" align="center" >
    <tr>
        <td>编号</td>
        <td>中药名</td>
        <td>别名</td>
        <td>归属类型</td>
        <td>操作</td>
    </tr>
    <%
        for(Tcm tcm:tcmList){	%>
    <tr>
        <td><%=tcm.getNumber() %> </td>
        <td><%=tcm.getName()   %> </td>
        <td><%=tcm.getAlias()    %> </td>
        <td>
            <%if (1==tcm.getType()){%>
            <%="上经"%>
            <%}else if (2==tcm.getType()){%>
            <%="中经"%>
            <%}else if (3==tcm.getType()){%>
            <%="下经"%>
            <%}else if (4==tcm.getType()){%>
            <%="增补"%>
            <%}else{%>
            <%="其他"%>
            <%}%>
        </td>
        <td>
            <a href="/TcmSystem/TcmServlet?action=detail&tcmid=<%=tcm.getId()%>">查看详情</a>&nbsp;
            <a href="/TcmSystem/TcmServlet?action=editUI&id=<%=tcm.getId()%>">编辑</a>&nbsp;
            <a href="#" onclick="del(<%=tcm.getId()%>)">删除</a>
        </td>
    </tr>
    <%} %>
</table>
<div align="center">
    第<%=curPage%>页
</div>
<div align="center">
    <a href="/TcmSystem/TcmServlet?action=list&curPage=<%=pu.getPrev()%>">上一页</a>
    <a href="/TcmSystem/TcmServlet?action=list&curPage=<%=pu.getNext()%>">下一页</a>
</div>
<div align="center">
   <button> <a href="/TcmSystem/TcmServlet?action=addUI">添加中药信息</a></button>
    <button><a href="/TcmSystem/index.jsp">返回首页</a></button>
</div>
<br/>

</body>
</html>
